
/*

Author   : chaos

FileName : stl_alg_sort.cpp

Date     : 17/08/17 16:11:36

*/
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
using namespace std;

template< class T>

void print(vector<T> & pri_con)
{
    if(pri_con.empty())
        cout << "Container is empty!" << endl;
    else{
        typename vector<T>::iterator i;

        for(i = pri_con.begin() ; i != pri_con.end(); i++)
        {
            cout << *i << " ";
            cout << endl;
        }
    }
}

int main(int argc ,char *argv[])
{
    char a[] = {'B','G','C','E'};
    vector<char> v1(a,a+4),v2(a,a+4);

    cout << "Sorting v1's element ..." << endl;
    sort(v1.begin() ,v1.end());
    print(v1);

    vector<char> v3(v1.size() + v2.size());

    cout << "Merge v1 and v2 ... " << endl;
    merge(v1.begin(),v1.end(),v2.begin(),v2.end(),v3.begin());

    print(v3);


    return 0;
}
